/*
 * Android Runner is a multiplayer GPS game fully written by Xurxo Mendez Perez
 * 
 * Copyright (C) 2009 Xurxo Mendez Perez
 *   
 * This file is part of Android Runner.
 * 
 * Android Runner is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Android Runner is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Android Runner.  If not, see <http://www.gnu.org/licenses/>.
 */

package es.sonxurxo.gpsgame.client.model.service.to.response;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import es.sonxurxo.gpsgame.client.model.service.to.Item;
import es.sonxurxo.gpsgame.client.model.service.to.Message;

/**
 * 
 * @author "Xurxo Mendez Perez"
 *
 */
public class GenericGameResponseTO implements Serializable {

	private List<Item> visibleItems = new ArrayList<Item>();
	private List<InGamePlayerInfoTO> inGamePlayerInfoTOs = new ArrayList<InGamePlayerInfoTO>();
	private List<Message> messages = new ArrayList<Message>();
	private boolean hasFinished = false;
	
	public GenericGameResponseTO(){}
	
	public GenericGameResponseTO(List<Item> visibleItems,
			List<InGamePlayerInfoTO> inGamePlayerInfoTOs, List<Message> messages, 
			boolean hasFinished) {
		super();
		this.visibleItems = visibleItems;
		this.inGamePlayerInfoTOs = inGamePlayerInfoTOs;
		this.messages = messages;
		this.hasFinished = hasFinished;
	}

	public boolean isHasFinished() {
		return hasFinished;
	}

	public void setHasFinished(boolean hasFinished) {
		this.hasFinished = hasFinished;
	}

	public List<InGamePlayerInfoTO> getInGamePlayerInfoTOs() {
		return inGamePlayerInfoTOs;
	}

	public void setInGamePlayerInfoTOs(List<InGamePlayerInfoTO> inGamePlayerInfoTOs) {
		this.inGamePlayerInfoTOs = inGamePlayerInfoTOs;
	}

		public Item getItem(long itemId) {
		for (Item item:visibleItems) {
			if (item.getItemId() == itemId)
				return item;
		}
		return null;
	}
	
	public InGamePlayerInfoTO getInGamePlayerInfoTO(String login) {
		for (InGamePlayerInfoTO igpiTO:inGamePlayerInfoTOs) {
			if (igpiTO.getLogin().equals(login))
				return igpiTO;
		}
		return null;
	}
	
//	public long getGameId() {
//		return gameId;
//	}
//
//	public void setGameId(long gameId) {
//		this.gameId = gameId;
//	}
//
//	public Calendar getStartDate() {
//		return startDate;
//	}
//
//	public void setStartDate(Calendar startDate) {
//		this.startDate = startDate;
//	}
//
//	public Calendar getFinishDate() {
//		return finishDate;
//	}
//
//	public void setFinishDate(Calendar finishDate) {
//		this.finishDate = finishDate;
//	}
//
//	public String getCity() {
//		return city;
//	}
//
//	public void setCity(String city) {
//		this.city = city;
//	}
//
//	public int getPointsToWin() {
//		return pointsToWin;
//	}
//
//	public void setPointsToWin(int pointsToWin) {
//		this.pointsToWin = pointsToWin;
//	}

	public List<Item> getVisibleItems() {
		return visibleItems;
	}

	public void setVisibleItems(List<Item> visibleItems) {
		this.visibleItems = visibleItems;
	}

	public List<Message> getMessages() {
		return messages;
	}

	public void setMessages(List<Message> messages) {
		this.messages = messages;
	}

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1873796874077898984L;

}
